<template>
  <div class="gpu-info">
    <el-card v-loading="loading">
      <div class="tab-header">
        <span>显卡信息</span>
        <el-icon class="refresh-icon" @click="refresh">
          <Refresh />
        </el-icon>
      </div>
      <el-table :data="info" border stripe>
        <el-table-column prop="name" label="名称" min-width="180" />
        <el-table-column prop="memory" label="显存" />
        <el-table-column prop="driver" label="驱动版本" min-width="140" />
        <el-table-column prop="processor" label="处理器" min-width="180" />
        <el-table-column prop="memory_type" label="显存类型" />
        <el-table-column prop="refresh_rate" label="刷新率" />
        <el-table-column prop="resolution" label="分辨率" />
        <el-table-column prop="status" label="状态" />
        <el-table-column prop="architecture" label="架构" />
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { Refresh } from '@element-plus/icons-vue'
import { getGpuInfo } from '/@/api/monitor'

const info = ref([] as any[])
const loading = ref(false)

const refresh = async () => {
  try {
    loading.value = true
    const { data } = await getGpuInfo()
    info.value = data.gpu
  } finally {
    loading.value = false
  }
}

defineExpose({
  refresh
})
</script>

<style lang="scss" scoped>
@import '../styles/common.scss';
</style> 